#include<iostream>
#include<sys/types.h>
#include<sys/stat.h>
#include<cstdio>
#include<fcntl.h>
#include<unistd.h>
using namespace std;
int main()
{
    int w_fd = open("file",O_WRONLY);
    while(true)
    {
        string message;
        cout<<"Please enter: ";
        getline(cin,message);
        write(w_fd,message.c_str(),message.size());
    }
    close(w_fd);
    return 0;
}
